/**
 * 项目名称:
 *
 * @Author: 夏国倩
 * @Date: 2023/10/12 14:05
 * @Copyright
 */
package multithreading;
/*
线程的合并
 */
public class ThreadTest11 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(new Processor11());
        t.setName("t");
        t.start();
        //合并线程
        t.join(); //t和主线程合并，单线程的程序
        //主线程
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName()+"---->"+i);
        }
    }
}
class Processor11 implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(Thread.currentThread().getName()+"---->"+i);
        }
    }
}
